import socket

def Main():
	host = '127.0.0.1'
	port = 50007
	
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	sock.bind((host, port))
	
	sock.listen(1)
	
	conn, addr = sock.accept()
	
	print ("Connection from: " + str(addr))
	while True:
		data = conn.recv(1024)
		if not data: break
		print ("Recv :" + str(data))
		data = str(data).upper()
		print ("Send :" + str(data))
		conn.send(data)

	conn.close()

# if __name__ == '__name__':
Main()
